package net.siufung.security.base.service;

import com.google.common.collect.Sets;
import net.siufung.security.base.CurrentClient;
import net.siufung.security.base.enums.TokenGranters;
import net.siufung.security.base.utils.PasswordUtil;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.Locale;

/**
 * @author 陈建峰
 * @date 2022/10/19 5:59 下午
 * @since V1.0.0
 */
public interface ICurrentClientService {

    /**
     * 获得授权Server 客户端ID
     * @param clientId 客户端Id
     * @return CurrentClient
     */
    default CurrentClient getAuthorizationClientById(String clientId){
        return new CurrentClient(
                "test_client",
                "$2a$10$2szDKjvKHJCWE6YQNznogOeQF3USZHmCYj1fG7YbfK.vnTgNKLzri",
                Sets.newHashSet("read", "write"),
                Sets.newHashSet(),
                Sets.newHashSet(TokenGranters.PASSWD.name().toLowerCase(Locale.ROOT),
                        TokenGranters.TOKEN.name().toLowerCase(Locale.ROOT)),
                86400,
                108000);
    };

    /**
     * 获得授权Server 密码加密方式
     * @return PasswordEncoder
     */
    default PasswordEncoder getAuthorizationPasswordEncoder() {
        return PasswordUtil.get();
    };
}
